package com.googlecode.sampleproject.action;

import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;

import com.googlecode.allinclusive.fw.valueobject.UserObject;
import com.googlecode.sampleproject.biz.A1000WBiz;
import com.googlecode.sampleproject.entity.UserEntity;

public class A1000WAction implements SessionAware {
	
	@Autowired
	A1000WBiz a1000WBiz;
	
	private UserEntity user;
	
	public String init() {
		return "self";
	}
	
	public String login() {
		UserObject userObject = a1000WBiz.login(user);
		if (userObject == null) {
			return "self";
		}
		
		session.put(UserObject.USER_OBJECT_KEY, userObject);
		return "success";
	}

	public UserEntity getUser() {
		return user;
	}
	public void setUser(UserEntity user) {
		this.user = user;
	}
	
	private Map<String, Object> session;
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
}
